<template>
  <div class="tixianinfo">
    <div class="slot">
      <div class="top">
        <div class="return" @click="goback">
          <img src="@/assets/my/zuo.png" alt />
        </div>
        <span>提现明细</span>
      </div>
    </div>
    <div class="main">
      <div class="top_title">
        <div :class="active===1?'li1':'li'" @click="changeactive(1)">
          <div class="p1">待审核</div>
          <span class="span"></span>
        </div>
         <div :class="active===2?'li1':'li'" @click="changeactive(2)">
          <div class="p1">已审核</div>
          <span class="span"></span>
        </div>
        <div :class="active===3?'li1':'li'" @click="changeactive(3)">
          <div class="p1">已提现</div>
          <span class="span"></span>
        </div>
      </div>
      <div class="center">
        <div class="main1">
          <van-pull-refresh v-model="isLoading" @refresh="onRefresh">
            <van-list
              :finished="finished"
              @load="onLoad"
              v-model="loading"
              finished-text="暂无数据了~"
              :immediate-check="false"
            >
              <div class="li2" v-for="item in list" :key="item.id">
                <div class="left">
                  <img src="@/assets/pblic/yuan.png" alt />
                  <div class="info">
                    <span class="top1">提现到微信</span>
                    <span class="time" v-show="active==1">{{item.add_time}}</span>
                    <span class="time" v-show="active==3">{{item.payment_time}}</span>
                  </div>
                </div>
                <div class="right">
                  ￥
                  <span>{{item.amount}}</span>
                </div>
              </div>
            </van-list>
          </van-pull-refresh>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import axios from "axios";
export default {
  data() {
    return {
      str: "",
      active: 1, //请求状态
      list: [],
      loading: false, //是否在上拉加载
      isLoading: false, //是否在刷新
      finished: false, //是否加载完成
      page: 1,
      total: 0,
      raw: 20,
      token:""
    };
  },
  created() {},
  mounted() {
    this.token = window.localStorage.getItem("token")
    this.onRefresh();
    var winHeight = document.documentElement.clientHeight; //视口大小
    document.getElementById("mian_ul").style.minHeight = winHeight - 82 + "px"; //调整上拉加载框高度
  },
  methods: {
    goback() {
      this.$router.back();
    },
    changeactive(active) {
      this.active = active;
      this.onRefresh();
    },
    // 下拉刷新
    onRefresh() {
      this.page = 1;
      this.finished = false;
      this.getList();
    },
    //上拉加载
    onLoad() {
      // 异步更新数据
      console.log("加载");
      this.page++;
      axios
        .post("/index/user/cash_detail", this.$qs.stringify({
          token: this.token,
          status: this.active,
          page: this.page,
        }))
        .then((res) => {
          var list1 = res.data.data.data;
          this.total = res.data.data.total;
          this.list1.forEach((item) => {
            this.list.push(item);
          });
          // 加载状态结束
          this.loading = false;
          // 数据全部加载完成
          if (this.list.length >= this.total) {
            this.finished = true;
          }
        });
    },
    getList() {
      axios
        .post("/index/user/cash_detail", this.$qs.stringify({
          token: this.token,
          status: this.active,
          page: this.page,
        }))
        .then((res) => {
          console.log(res.data, 456789);
          this.list = res.data.data.data;
          this.total = res.data.data.total;
          this.isLoading = false;
          if (this.list.length >= this.total) {
            this.finished = true;
          }
        });
    },
  },
  beforeCreate() {
    document
      .querySelector("body")
      .setAttribute("style", "background-color:#F8F8F8");
  },
  beforeDestroy() {
    document.querySelector("body").setAttribute("style", "");
  },
};
</script>


<style lang="scss" scoped>
.slot {
  width: 100%;
  height: 44px;
  .top {
    width: 100%;
    height: 44px;
    display: flex;display: -webkit-flex;
    justify-content: center;
    align-items: center;
    background: white;
    position: fixed;
    top: 0;
    left: 0;
    .return {
      width: 38px;
      height: 100%;
      position: absolute;
      top: 0;
      left: 0;
      display: flex;display: -webkit-flex;
      justify-content: center;
      align-items: center;
      img {
        width: 8px;
        height: 15px;
      }
    }
    span {
      font-size: 18px;
      font-family: PingFang SC;
      font-weight: bold;
      color: #000000;
      line-height: 44px;
    }
  }
}
.main {
  width: 100%;
  background: white;
  .top_title {
    width: 100%;
    height: 45px;
    background: #ffffff;
    display: flex;display: -webkit-flex;
    border-bottom: 1px solid #f8f8f8;
    position: fixed;
    top: 44px;
    left: 0;
    z-index: 6;
    .li {
      width: 50%;
      height: 100%;
      display: flex;display: -webkit-flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      text-align: center;
      .p1 {
        font-size: 15px;
        font-family: PingFang SC;
        font-weight: 500;
        color: #888888;
        line-height: 15px;
      }
    }
    .li1 {
      width: 50%;
      height: 100%;
      display: flex;display: -webkit-flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      text-align: center;
      position: relative;
      .p1 {
        font-size: 18px;
        font-family: PingFang SC;
        font-weight: bold;
        color: #000000;
        line-height: 18px;
      }
      .span {
        width: 28px;
        height: 4px;
        background: #fdd40a;
        border-radius: 2px;
        position: absolute;
        bottom: 0;
      }
    }
  }
  .center {
    width: 100%;
    background: white;
    margin-top: 45px;
    .main1 {
      width: 345px;
      margin: auto;
      .li2 {
        width: 100%;
        height: 75px;
        border-bottom: 1px solid #f8f8f8;
        display: flex;display: -webkit-flex;
        align-items: center;
        justify-content: space-between;
        .left {
          display: flex;display: -webkit-flex;
          align-items: center;
          img {
            width: 35px;
            height: 35px;
            margin-right: 10px;
          }
          .info {
            display: flex;display: -webkit-flex;
            flex-direction: column;
            align-items: flex-start;
            .top1 {
              font-size: 16px;
              font-family: PingFang SC;
              font-weight: 500;
              color: #222222;
              line-height: 16px;
            }
            .time {
              font-size: 12px;
              font-family: PingFang SC;
              font-weight: 500;
              color: #bcbcbc;
              line-height: 12px;
              margin-top: 10px;
            }
          }
        }
        .right {
          font-size: 12px;
          font-family: PingFang SC;
          font-weight: 500;
          color: #4c78fa;
          line-height: 12px;
          span {
            font-size: 17px;
          }
        }
      }
    }
  }
}
</style>